/********************************************************/
/*	Copyright (C) 2016 Gong Li Bin		 	*/
/*	Project:	GoLib-1.0.0			*/
/*	Author:		gong_libin			*/
/*	Date:		2016_01_01			*/
/*	File:		GoLock.go			*/
/********************************************************/

package GoCls

import (
	"sync"
)

/* Mutex Lock */
type GoLock struct {
	lock	*sync.Mutex
}

func (l *GoLock) GoLockGet() *sync.Mutex {
	return  l.lock
}

func (l *GoLock) GoLockPut(lk *sync.Mutex) {
	l.lock = lk
}

func (l *GoLock) GoLockInit() {
	l.lock = &sync.Mutex{}
}

func (l *GoLock) GoLockLock() {
	l.lock.Lock()
}

func (l *GoLock) GoLockUnlock() {
	l.lock.Unlock()
}

/* Mutex RwLk */
type GoRwLk struct {
	rwlk	*sync.RWMutex
}

func (l *GoRwLk) GoRwLkGet() *sync.RWMutex {
	return  l.rwlk
}

func (l *GoRwLk) GoRwLkPut(lk *sync.RWMutex) {
	l.rwlk = lk
}

func (l *GoRwLk) GoRwLkInit() {
	l.rwlk = &sync.RWMutex{}
}

func (l *GoRwLk) GoRwLkRLock() {
	l.rwlk.RLock()
}

func (l *GoRwLk) GoRwLkRUnlock() {
	l.rwlk.RUnlock()
}

func (l *GoRwLk) GoRwLkWLock() {
	l.rwlk.Lock()
}

func (l *GoRwLk) GoRwLkWUnlock() {
	l.rwlk.Unlock()
}
